package com.dimenlink.admin.controller;

import com.dimenlink.entity.query.VideoInfoPostQuery;
import com.dimenlink.entity.vo.PaginationResultVO;
import com.dimenlink.entity.vo.ResponseVO;
import com.dimenlink.service.VideoInfoFilePostService;
import com.dimenlink.service.VideoInfoPostService;
import com.dimenlink.service.VideoInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/videoInfo")
@Validated
@Slf4j
public class VideoInfoController extends ABaseController{
    @Resource
    private VideoInfoPostService videoInfoPostService;
    @Resource
    private VideoInfoFilePostService videoInfoFilePostService;
    @Resource
    private VideoInfoService videoInfoService;

    @RequestMapping("/loadVideoList")
    public ResponseVO loadVideoPost(VideoInfoPostQuery videoInfoPostQuery) {
        // 设置按最后更新时间倒序排序，让最新更新的视频排在前面展示
        videoInfoPostQuery.setOrderBy("t.last_update_time desc");
        // 设置查询数量信息（比如总条数等统计数据 ），为后续分页等功能提供统计依据
        videoInfoPostQuery.setQueryCountInfo(true);
        // 设置查询用户信息，让结果中包含发布视频的用户相关信息
        videoInfoPostQuery.setQueryUserInfo(true);
        // 调用 service 层方法，根据查询条件进行分页查询视频帖子列表
        PaginationResultVO resultVO = videoInfoPostService.findListByPage(videoInfoPostQuery);
        // 将查询结果封装成成功响应返回给前端
        return getSuccessResponseVO(resultVO);
    }

    @RequestMapping("/audiVideo")
    public ResponseVO audiVideo(@NotEmpty String videoId, @NotNull Integer  status, String reason) {
    	videoInfoPostService.auditVideo(videoId, status, reason);
        return getSuccessResponseVO(null);
    }
}
